﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;

namespace ReciteWordsDataBase
{
    public partial class Form1 : Form
    {
        
        
        string Path ;
        string dbname ;
        string ReciteWord1 = "";
        string ReciteWord2 = "";
        string ReciteWord3 = "";
        string ReciteWord4 = "";
        string ReciteWord5 = "";
        public Form1()
        {
            InitializeComponent();
            OpenFileDialog of = new OpenFileDialog();
            of.ShowDialog();
            dbname = of.SafeFileName;
            Path = "Data Source=" + dbname +";charset=utf8";

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            SQLiteConnection connection = new SQLiteConnection(Path);
            connection.Open();
            string sqlStr = "SELECT Eword FROM words WHERE Cmeaning = " + "'放弃'";
            SQLiteCommand command = new SQLiteCommand(sqlStr, connection);
            SQLiteDataReader reader = command.ExecuteReader();
            reader.Read();
            if(ReciteWord1 == reader["Eword"].ToString())
            {
                label16.Text = "正确";
            }
            else if (ReciteWord1 == "")
            {
                label16.Text = "不可为空";
            }
            else
            {
                label16.Text = "错误";
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            ReciteWord1 = textBox1.Text;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            ReciteWord2 = textBox2.Text;
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            ReciteWord3 = textBox3.Text;
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {
            ReciteWord4 = textBox4.Text;
        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {
            ReciteWord5 = textBox5.Text;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SQLiteConnection connection = new SQLiteConnection(Path);
            connection.Open();
            string sqlStr = "SELECT Eword FROM words WHERE Cmeaning = " + "'香蕉'";
            SQLiteCommand command = new SQLiteCommand(sqlStr, connection);
            SQLiteDataReader reader = command.ExecuteReader();
            reader.Read();
            if (ReciteWord2 == reader["Eword"].ToString())
            {
                label17.Text = "正确";
            }
            else if (ReciteWord2 == "")
            {
                label17.Text = "不可为空";
            }
            else
            {
                label17.Text = "错误";
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SQLiteConnection connection = new SQLiteConnection(Path);
            connection.Open();
            string sqlStr = "SELECT Eword FROM words WHERE Cmeaning = " + "'时钟'";
            SQLiteCommand command = new SQLiteCommand(sqlStr, connection);
            SQLiteDataReader reader = command.ExecuteReader();
            reader.Read();
            if (ReciteWord3 == reader["Eword"].ToString())
            {
                label18.Text = "正确";
            }
            else if (ReciteWord3 == "")
            {
                label18.Text = "不可为空";
            }
            else
            {
                label18.Text = "错误";
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            SQLiteConnection connection = new SQLiteConnection(Path);
            connection.Open();
            string sqlStr = "SELECT Eword FROM words WHERE Cmeaning = " + "'前夜'";
            SQLiteCommand command = new SQLiteCommand(sqlStr, connection);
            SQLiteDataReader reader = command.ExecuteReader();
            reader.Read();
            if (ReciteWord4 == reader["Eword"].ToString())
            {
                label19.Text = "正确";
            }
            else if (ReciteWord4 == "")
            {
                label16.Text = "不可为空";
            }
            else
            {
                label19.Text = "错误";
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            SQLiteConnection connection = new SQLiteConnection(Path);
            connection.Open();
            string sqlStr = "SELECT Eword FROM words WHERE Cmeaning = " + "'鸭子'";
            SQLiteCommand command = new SQLiteCommand(sqlStr, connection);
            SQLiteDataReader reader = command.ExecuteReader();
            reader.Read();
            if (ReciteWord5 == reader["Eword"].ToString())
            {
                label20.Text = "正确";
            }
            else if (ReciteWord5 == "")
            {
                label20.Text = "不可为空";
            }
            else
            {
                label20.Text = "错误";
            }
        }
    }
}
